
<!-- HTML for static distribution bundle build -->
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <title>Swagger UI</title>
    <link rel="stylesheet" type="text/css" href="swaggerui/swagger-ui.css" >
    <link rel="icon" type="image/png" href="swaggerui/favicon-32x32.png" sizes="32x32" />
    <link rel="icon" type="image/png" href="swaggerui/favicon-16x16.png" sizes="16x16" />
    <style>
      html
      {
        box-sizing: border-box;
        overflow: -moz-scrollbars-vertical;
        overflow-y: scroll;
      }

      *,
      *:before,
      *:after
      {
        box-sizing: inherit;
      }

      body
      {
        margin:0;
        background: #fafafa;
      }
    </style>
  </head>

  <body>
    <div id="swagger-ui"></div>

    <script src="swaggerui/swagger-ui-bundle.js" charset="UTF-8"> </script>
    <script src="swaggerui/swagger-ui-standalone-preset.js" charset="UTF-8"> </script>
    <script>
      function httpGet(theUrl)
      {
        var xmlHttp = new XMLHttpRequest();
        xmlHttp.open( "GET", theUrl, false ); // false for synchronous request
        xmlHttp.send( null );
        return xmlHttp.responseText;
      }
    </script>
    <script>
      window.addEventListener("DOMContentLoaded", async () => {
        const specResponse = await fetch("./swagger.json");
        console.log("Response: ", specResponse);

        const spec = await specResponse.json();
        console.log("JSON: ", spec);

        const tokenResponse = await fetch("/authenticationTest.html?csrf");
        const token = await tokenResponse.text();
        console.log("Token: ", token);

        const ui = SwaggerUIBundle({
          url: window.location.origin + "/app/rest/swagger.json",
          dom_id: '#swagger-ui',
          deepLinking: true,
          spec: spec,
          presets: [
            SwaggerUIBundle.presets.apis,
            SwaggerUIStandalonePreset
          ],
          plugins: [
            SwaggerUIBundle.plugins.DownloadUrl
          ],
          layout: "StandaloneLayout",
          requestInterceptor: (req) => {
            req.headers["X-TC-CSRF-Token"] = token
            return req;
          }
        });
      });
  </script>
  </body>
</html>